package com.btl.helper.mp;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.nio.file.Paths;

public class CodeGenAgent {
    public static void main(String[] args) {
        String projectPath = Paths.get(System.getProperty("user.dir")) + "/btl-helper/btl-helper-mybatis-plus/src/main/java";
        String url = "jdbc:mysql://192.168.130.151:3306/btl-agent?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true";
        String username = "root";
        String password = "Boatlink@123456";
        FastAutoGenerator.create(url, username, password)
                .globalConfig(builder -> builder
                        .author("Tim")
                        .outputDir(projectPath)
                        .commentDate("yyyy-MM-dd")
                )
                .packageConfig(builder -> builder
                        .parent("com.btl.service.client.biz")
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .xml("mapper.xml")
                )
                .strategyConfig(builder -> builder
                        .entityBuilder()
                        .enableTableFieldAnnotation() // 启用字段注解
                        .enableLombok()
                        .enableTableFieldAnnotation()
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
